<script setup lang="ts">
import { StarFilled, Document } from '@element-plus/icons-vue'
import useColumnList from '@/components/index/followig/hooks/columnList'
const { listData, isSelected, page, showPage, pageSize, pageTotal, select, clickPage, clickTo } =
  useColumnList()
</script>

<template>
  <el-pagination
    ref="page"
    background
    layout="prev, pager, next"
    :hide-on-single-page="true"
    v-show="showPage"
    :page-size="pageSize"
    :total="pageTotal"
    @current-change="clickPage($event)"
  />
  <ul id="clumns">
    <li
      v-for="item in listData"
      :key="item.id"
      :class="{ active: isSelected === item.id }"
      @click="clickTo(item)"
    >
      <div>
        <img class="clumnsImg" :src="item.img" alt="" />
      </div>
      <div>
        <p class="top">
          <b>{{ item.name }}</b>
        </p>
        <p class="center">
          <StarFilled class="svg" />
          <span>{{ item.followed }}</span>
          <Document class="svg" />
          <span>{{ item.total }}</span>
        </p>
        <p class="bottom">
          <b>{{ 'by：' + item.by }}</b>
        </p>
      </div>
    </li>
  </ul>
</template>

<style scoped>
div {
  justify-content: center;
  margin-bottom: 10px;
  --el-color-primary: var(--color2);
}
.active {
  outline: 2px solid var(--color3);
  color: #fff;
}
.clumnsImg {
  display: inline-block;
  vertical-align: middle;
  width: 56px;
  height: 56px;
  margin: 8px;
}
.svg {
  width: 16px;
  height: 16px;
  padding: 0 4px;
  display: inline-block;
  vertical-align: middle;
}
#clumns {
  list-style: none;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  grid-auto-rows: 72px;
  gap: 10px;
  > li:hover {
    cursor: pointer;
    outline: 2px solid var(--color3);
    color: #fff;
  }

  > li {
    border-radius: var(--radius);
    overflow: hidden;
    background-color: var(--color2);

    > div:nth-child(2) {
      height: 72px;
      width: calc(100% - 72px);
      box-sizing: border-box;
    }
    > div {
      display: inline-block;
      vertical-align: middle;
      > p {
        padding: 2px 0;
        > span {
          display: inline-block;
          vertical-align: middle;
        }
      }
    }

    .top {
      height: 20px;
      line-height: 20px;
      padding-left: 4px;
      b {
        max-width: 200px;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
    .center {
      height: 23px;
      box-sizing: border-box;
    }
    .bottom {
      height: 20px;

      text-align: end;
      padding-right: 20px;
      line-height: 20px;
      b {
        margin-right: 6px;
        font-weight: normal;
        max-width: 120px;
        white-space: nowrap;
        text-overflow: ellipsis;
      }
    }
  }
}
</style>
